﻿using System;

namespace Quail.DbLogger.Task
{
    public class StoreMonitorLogEntry : QuailDbLoggerEntry
    {
        private readonly int TestRunId;
        private readonly string Message;
        private readonly int TestMonitorTypeId;
        private readonly int TaskStatusId;
        private readonly DateTime TaskNow;

        public StoreMonitorLogEntry(int testrunid, LogStatus status, Enum scenario, string message, DateTime logtime)
        {
            TestMonitorTypeId = Convert.ToInt32(scenario);
            TaskStatusId = (int) status;
            Message = message;
            TestRunId = testrunid;
            TaskNow = logtime;
        }

        public override void Store(QuailServices.QuailDataServiceReference.QuailDataServiceClient context)
        {
            context.InsertTestMonitor(TestMonitorTypeId, TaskStatusId, TaskNow, TestRunId, Message);
        }

        /// <summary>
        /// Returns a string representation of the entry for logging purposes
        /// </summary>
        /// <returns>A log string</returns>
        public override string GetLogDetail()
        {
            return string.Format("StoreMonitorLogEntry({0},{1},{2},{3},{4})", TestMonitorTypeId, TaskStatusId, TaskNow, TestRunId, Message);
        }
    }
}
